deferred class IUP_WIDGET_CHILD
-- Commands to handle the attributes related with the child.

inherit
	IUP_WIDGET_INTERNALS
	
feature {ANY}

	-- Attributes to be used inside a container.
	set_cx (cx: INTEGER)
		-- X coordinate of the position to be used inside a IUP_CBOX container.
		require
			non_negative: cx >= 0
		do
			iup_open.set_attribute(Current, "CX", cx.out)
		end

	get_cx: INTEGER
		-- Return the x coordinate used inside a IUP_CBOX container.
		local
			cx: STRING
		do
			cx := iup_open.get_attribute(Current, "CX")
			Result := cx.to_integer
		end

	set_cy (cy: INTEGER)
		-- Y coordinate of the position to be used inside a IUP_CBOX container.
		require
			non_negative: cy >= 0
		do
			iup_open.set_attribute(Current, "CY", cy.out)
		end

	get_cy: INTEGER
		-- Return the y coordinate used inside a IUP_CBOX container.
		local
			cy: STRING
		do
			cy := iup_open.get_attribute(Current, "CY")
			Result := cy.to_integer
		end

	set_expand_weight (value: INTEGER)
		-- (non inheritable) (at children only): If a child defines the expand 
		-- weight, then it is used to multiply the free space used for expansion.
		do
			iup_open.set_attribute(Current, "EXPANDWEIGHT", value.out)
		end

	get_expand_weight: INTEGER
		-- Return the value of expandweight.
		local
			str: STRING
		do
			str := iup_open.get_attribute(Current, "EXPANDWEIGHT")
			Result := str.to_integer
		end

	set_tab_title (value: STRING)
		-- (non inheritable) (at children only): Same as TABTITLEn in 
		-- IUP_TABS but set in each child. Works only if set before the child is 
		-- added to the tabs.
		do
			iup_open.set_attribute(Current, "TABTITLE", value)
		end

	get_tab_title: STRING
		-- Return the value of tabtitle.
		do
			Result := iup_open.get_attribute(Current, "TABTITLE")
		end

	set_tab_image (value: STRING)
		-- (non inheritable) (at children only): Same as TABIMAGEn in 
		-- IUP_TABS but set in each child. Works only if set before the child is 
		-- added to the tabs.
		do
			iup_open.set_attribute(Current, "TABIMAGE", value)
		end

	get_tab_image: STRING
		-- Return the value of tabimage.
		do
			Result := iup_open.get_attribute(Current, "TABIMAGE")
		end

	-- Commands to handle the hierarchy
	detach
		-- Detaches the interface element from its parent.
		do
			iup_open.iup_detach(Current)
		end
	
	get_parent: detachable IUP_CONTAINER
		-- Return the parent of the element or void if does not have a parent.
		do
			if attached {IUP_CONTAINER} iup_open.iup_get_parent(Current) as pr then
				Result := pr
			end
		end

	get_brother: detachable IUP_WIDGET
		-- Return the next element in the parent where this element is 
		-- placed or void if there is none.
	
		do
			Result := iup_open.iup_get_brother(Current)
		end

	get_dialog: detachable IUP_DIALOG
		-- Returns the dialog that contains this interface element. Works 
		-- also for children of a menu that is associated with a dialog.
		-- Returns: the dialog or void if not found.
		do
			if attached {IUP_DIALOG} iup_open.iup_get_dialog(Current) as dlg then
				Result := dlg
			end
		end

	set_normalizer_group (name: STRING)
		-- (non inheritable): name of a normalizer element to which to 
		-- automatically add the control. If an element with that name does not 
		-- exists then one is created.
		do
			iup_open.set_attribute(Current, "NORMALIZERGROUP", name)
		end

	-- For widgets at IUP_MULTI_BOX
	set_line_break (state: BOOLEAN)
		-- Force a line break after the child when ORIENTATION=HORIZONTAL. 
		do
			if state then
				iup_open.set_attribute(Current, "LINEBREAK", "YES")
			else
				iup_open.set_attribute_null(Current, "LINEBREAK")
			end
		end

	set_column_break (state: BOOLEAN)
		-- Force a column break after the child when ORIENTATION=VERTICAL.
		do
			if state then
				iup_open.set_attribute(Current, "COLUMNBREAK", "YES")
			else
				iup_open.set_attribute_null(Current, "COLUMNBREAK")
			end
		end
	
end

-- The MIT License (MIT)

-- Copyright (c) 2016, 2017, 2018, 2019 by German A. Arias

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in 
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
